package com.jia.springcloud.controller;

import com.jia.springcloud.entities.CommonResult;
import com.jia.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 1038940655
 * @create 2021/1/21 19:08
 */
@RestController
@Slf4j
public class OrderFeignController {
    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping("/consumer/getFeign/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Integer id){
        return paymentFeignService.getPaymentById(id);
    }

//    这里面肯定会报错，因为feign默认网络延迟是1秒，而我们在接口中自己创建了一个3秒的延迟所以会报错
//    要想不报错，就需要在application.yml中设置feign
    @RequestMapping("/consumer/feign/timeout")
    public String paymentFeignTimeout(){
        return paymentFeignService.paymentFeignTimeout();
    }
}
